package com.jplus.controller;

import com.jplus.VO.ResultVO;
import com.jplus.entity.User;
import com.jplus.handler.GlobalExceptionHandler;
import com.jplus.service.LoginService;
import com.jplus.utils.ResultVOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
public class LoginController extends GlobalExceptionHandler {

    @Autowired
    private LoginService loginService;

    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public ResultVO loginAction(User user, HttpSession session, HttpServletRequest request) {
        return loginService.loginAction(user, session, request);
    }

    @RequestMapping(value = "/logout", method = RequestMethod.GET)
    public ResultVO logoutAction(String sessionId) {
        return loginService.logOutAction(sessionId);
    }
}

